
// 引入AES.js
var baseJs = require("../../common/base.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrl: baseJs.imgUrl,
    listData:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      uid: wx.getStorageSync('uid'),
    })
    this.GetStateBarTypeList();
  },

  GetStateBarTypeList: function () {
    var that = this;
    var uid = this.data.uid;
    var listData = this.data.listData;
    wx.request({
      url: baseJs.api + baseJs.encryUrl("method=GetStateBarTypeList&UID=" + uid),
      success: function (res) {
        listData = JSON.parse(baseJs.decryUrl(res.data)).ResultData;
        console.log(listData);
        that.setData({
          listData: listData,
        })
      }
    })
  },
  // 
  guanZhu:function(e){
    var that = this;
    var uid = this.data.uid;
    wx.request({
      url: baseJs.api + baseJs.encryUrl("method=FollowBarType&UID=" + uid + "&BarId=" + e.currentTarget.dataset.id),
      success: function (res) {
        var json = JSON.parse(baseJs.decryUrl(res.data));
        console.log(JSON.parse(baseJs.decryUrl(res.data)));
        if (json.ResultFlag == 1){
          wx.showToast({
            title: json.ResultMsg,
            icon: 'none',
            duration: 2000
          });
        }else{
          wx.showToast({
            title: json.ResultMsg,
            icon: 'none',
            duration: 2000
          });
        }
        that.GetStateBarTypeList();
      }
    })
  },
  // 
  cancelGuanZhu:function(e){
    var that = this;
    var uid = this.data.uid;
    wx.request({
      url: baseJs.api + baseJs.encryUrl("method=CancleFollowBarType&UID=" + uid + "&BarId=" + e.currentTarget.dataset.id),
      success: function (res) {
        var json = JSON.parse(baseJs.decryUrl(res.data));
        console.log(JSON.parse(baseJs.decryUrl(res.data)));
        if (json.ResultFlag == 1) {
          wx.showToast({
            title: json.ResultMsg,
            icon: 'none',
            duration: 2000
          });
        } else {
          wx.showToast({
            title: json.ResultMsg,
            icon: 'none',
            duration: 2000
          });
        }
        that.GetStateBarTypeList();
      }
    })
  },
})